<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_game.xhtml">

	<ui:define name="centro">

		<h:form id="form">
			<p:messages id="messages" showDetail="true" autoUpdate="true" />
			
			<p:dataTable id="listaMembro" var="membro" value="#{membroMBean.membros}" paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum nível cadastrado" filteredValue="#{membroMBean.membrosFiltro}"
				resizableColumns="true" selectionMode="single" rowKey="#{membro.id}" selection="#{membroMBean.membro}">

				<p:ajax event="rowSelect" update=":form:formulario" oncomplete="membroDialog.show()" />

				<f:facet name="header">
					Lista de Membros do Jogador
				</f:facet>

				<p:column headerText="Código">
					<p:outputLabel value="#{membro.id}" />
				</p:column>

				<p:column headerText="Nome" sortBy="#{membro.nome}" filterBy="#{membro.nome}" filterMatchMode="contains">
					<p:outputLabel value="#{membro.nome}" />
				</p:column>

				<p:column headerText="Classificação">
					<p:outputLabel value="#{membro.classificacao.descricao}" />
				</p:column>

				<p:column headerText="Data Contratação">
					<p:outputLabel value="#{membro.dataCadastro}" />
				</p:column>

				<p:column headerText="Status">
					<p:outputLabel value="#{membro.status}" />
				</p:column>

				<p:column headerText="Data Status">
					<p:outputLabel value="#{membro.dataStatus}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton value="Contratar" icon="ui-icon-plus" action="#{membroMBean.novo}" />
				</f:facet>
			</p:dataTable>

			<p:dialog header="Membro" widgetVar="membroDialog" resizable="false" showEffect="clip" hideEffect="fold">
				<h:panelGrid id="formulario" columns="2" cellpadding="4">

					<p:outputLabel value="Nome" />
					<p:inputText value="#{membroMBean.membro.nome}" />

					<p:commandButton action="#{membroMBean.salvar}" value="Salvar" update=":form:listaMembro" oncomplete="membroDialog.hide()"/>

				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>

</ui:composition>

</html>
